//index.js
//获取应用实例
const app = getApp();
// var template = require('../header/header.js');

Page({
    data: {
        money: '',
    },
    onLoad: function () {

    },
    onHide: function () {
    },

    bindChange: function(e){
        this.setData({
            money: e.detail.value
        })
    },
    recharge: function(){
        var object = {
            url: app.api.url.user.moneyRecharge,
            data: {money: this.data.money},
            success: function(res) {
                // 调微信api支付
                wx.requestPayment({
                    'timeStamp': res.data.timeStamp,
                    'nonceStr': res.data.nonceStr,
                    'package': res.data.package,
                    'signType': 'MD5',
                    'paySign': res.sign,
                    'success':function(res){
                        app.navigateBack();
                    },
                    'fail':function(res){
                        app.alert('支付失败');
                    },
                    'complete':function(res){
                    }
                })
            }
        }
    }
});
